package com.jsz.peini.server.thread;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.jsz.peini.bean.order.GoldHistory;
import com.jsz.peini.bean.order.GoldHistoryExample;
import com.jsz.peini.bean.order.GoldHistoryExample.Criteria;
import com.jsz.peini.bean.order.PayStream;
import com.jsz.peini.bean.order.PayStreamExample;
import com.jsz.peini.bean.user.UserAccount;
import com.jsz.peini.bean.user.UserInfo;
import com.jsz.peini.bean.user.UserInfoExample;
import com.jsz.peini.common.util.DateTimeUtils;
import com.jsz.peini.mapper.order.GoldHistoryMapper;
import com.jsz.peini.mapper.order.PayStreamMapper;
import com.jsz.peini.mapper.user.UserAccountMapper;
import com.jsz.peini.mapper.user.UserInfoMapper;
import com.jsz.peini.redis.util.UserRedisUtil;
import com.jsz.peini.vo.UserVo;

@Component
public class RankDBServer {
	
	@Resource
	private UserInfoMapper userInfoMapper;
	@Resource
	private GoldHistoryMapper goldHistoryMapper;
	@Resource
	private UserAccountMapper userAccountMapper;
	@Resource
	private PayStreamMapper payStreamMapper;
	
	public static boolean flag = false;
	public static Timer timer;

	public RankDBServer() {
		
	}
	
	public void init(){
		startTimer();
	}
	
	public static void stopTimer(){
		flag = false;
		timer.cancel();
	}
	
	public void startTimer(){
		flag = true;
		
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.HOUR_OF_DAY, 3);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		final Date timerDate = calendar.getTime();
		
		timer = new Timer();
		
		timer.schedule(new TimerTask() {
			@Override
			public void run() {
				Calendar calendar1 = Calendar.getInstance();
				int cnt = calendar1.get(Calendar.DAY_OF_MONTH);
				if(cnt == 1){//每月1日3点0分执行
					
				}
			}
		}, timerDate);
	}
}
